package com.example.mapping.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.example.mapping.common.core.ResultResponse;
import com.example.mapping.dto.RuleDto;
import com.example.mapping.dto.RuleQueryDto;
import com.example.mapping.dto.ValueMappingDto;
import com.example.mapping.dto.ValueMappingQueryDto;
import com.example.mapping.manage.RuleManage;
import com.example.mapping.manage.ValueMappingManage;
import com.example.mapping.vo.RuleVo;
import com.example.mapping.vo.ValueMappingVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* (value_mapping)表控制层
 * @author baoyoujia
 */
@RestController
@RequestMapping("/value_mapping")
public class ValueMappingController {

    @Autowired
    private ValueMappingManage valueMappingManage;

    @GetMapping("/value")
    public ResultResponse<PageDTO<ValueMappingVo>> getValueListByPage(ValueMappingQueryDto valueMappingQueryDto) {
        return ResultResponse.buildSuccess(valueMappingManage.getValueByPage(valueMappingQueryDto));
    }

    @GetMapping("/{id}")
    public ResultResponse<ValueMappingVo> get(@PathVariable("id") Long id) {
        return ResultResponse.buildSuccess(valueMappingManage.getValueMapping(id));
    }

    @PostMapping("/value")
    public ResultResponse<Boolean> add(@RequestBody ValueMappingDto ruleDto) {
        return ResultResponse.buildSuccess(valueMappingManage.addValueMapping(ruleDto));
    }

    @PutMapping("/{id}")
    public ResultResponse<Boolean> edit(@PathVariable("id") Long id, @RequestBody ValueMappingDto ruleDto) {
        ruleDto.setId(id);
        return ResultResponse.buildSuccess(valueMappingManage.editValueMapping(ruleDto));
    }

    @DeleteMapping("/{id}")
    public ResultResponse<Boolean> del(@PathVariable("id") Long id) {
        return ResultResponse.buildSuccess(valueMappingManage.delValueMapping(id));
    }

}
